package cn.lili.modules.payment.mapper;

import cn.lili.modules.payment.entity.dos.OutOrderDetailLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 分账详细记录
 *
 * @author Bulbasaur
 * @since 2022/10/19
 **/
public interface OutOrderDetailLogMapper extends BaseMapper<OutOrderDetailLog> {

    @Select("SELECT count(*) as orderCount,sum(a.amount) as sumAmount, a.* " +
            "FROM li_out_order_detail_log a " +
            "WHERE sub_mchid != '-1' and sub_mchid = #{subMchid} " +
            "GROUP BY sub_mchid, order_sn HAVING orderCount > 1 " +
            "ORDER BY create_time DESC")
    List<OutOrderDetailLog> shareProfitStrike(@Param("subMchid") String subMchid);

    void deleteShareProfit(@Param("ids") List<String> ids);

}
